﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._20_备忘录模式
{
    /// <summary>
    /// 备忘录存储
    /// </summary>
    public class EditorHistory
    {
        private readonly Stack<EditorMemento> _history = new();

        public void Push(EditorMemento memento)
        {
            Console.WriteLine($"发布内容：{memento.Content}");
            _history.Push(memento);
        }

        public EditorMemento Pop()
        {
            return _history.Pop();
        }

        public bool CanUndo => _history.Count > 0;

    }
}
